import React, {Component} from 'react';
import BaseOpts from '../BaseOpts';
import './index.css';
import {InputNumber, Slider, Radio, Button} from 'antd';
import SlideInput from '../../common/SlideInput/index';

const RadioGroup = Radio.Group;

class MSwiperOpts extends BaseOpts {

    static defaultProps = {
        data: {
            style: {},
            dataset: {}
        }
    };


    constructor(props) {
        super(props);

        this.state = {
            data: props.data
        };

    }

    render() {
        var {style, dataset, layout, direction, isFull} = this.state.data;
        var marginTop = parseFloat(style.marginTop || 0);
        var marginBottom = parseFloat(style.marginBottom || 0);
        var direction = direction || 'row';
        var isFull = isFull || '0';

        return (
            <div className="optsPanel">
                <div className="optsPanel__item">
                    <label className="optsPanel__item__hd">布局</label>
                    <div className="optsPanel__item__bd">
                        <RadioGroup onChange={(e) => {
                            this.$dataChange('layout', e.target.value, false);
                        }} value={layout}>
                            <Radio value={0}>轮播图</Radio>
                            <Radio value={1}>向下平铺</Radio>
                        </RadioGroup>
                    </div>
                </div>

                {
                    layout == 0 ?
                        (
                            <div>
                                <div className="optsPanel__item">
                                    <label className="optsPanel__item__hd">轮播方向</label>
                                    <div className="optsPanel__item__bd">
                                        <RadioGroup onChange={(e) => {
                                            this.$dataChange('direction', e.target.value, false);
                                        }} defaultValue={direction}>
                                            <Radio value={'row'}>横向</Radio>
                                            <Radio value={'column'}>竖向</Radio>
                                        </RadioGroup>
                                    </div>
                                </div>

                                <div className="optsPanel__item">
                                    <label className="optsPanel__item__hd">轮播是否满屏</label>
                                    <div className="optsPanel__item__bd">
                                        <RadioGroup onChange={(e) => {
                                            this.$dataChange('isFull', e.target.value, false);
                                        }} defaultValue={isFull}>
                                            <Radio value={'0'}>否</Radio>
                                            <Radio value={'1'}>是</Radio>
                                        </RadioGroup>
                                    </div>
                                </div>
                            </div>
                        )
                        : null
                }

                <div className="optsPanel__item">
                    <label className="optsPanel__item__hd">上外边距</label>
                    <div className="optsPanel__item__bd">
                        <SlideInput step={1} min={0} max={100} value={marginTop} onChange={(val) => {
                            this.$dataChange('marginTop', val + 'px', 'style');
                        }}/>
                    </div>
                </div>

                <div className="optsPanel__item">
                    <label className="optsPanel__item__hd">下外边距</label>
                    <div className="optsPanel__item__bd">
                        <SlideInput step={1} min={0} max={100} value={marginBottom} onChange={(val) => {
                            this.$dataChange('marginBottom', val + 'px', 'style');
                        }}/>
                    </div>
                </div>

                <div className="optsPanel__item">
                    <div className="optsPanel__item__bd">
                        <a href="/admin/Banner/listPage?show_type=1" target="_blank"
                           className="ant-btn-dataMng ant-btn ant-btn-primary ant-btn-lg">数据管理</a>
                    </div>
                </div>
            </div>
        );
    }
}

export default MSwiperOpts;
